package com.itcast.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class ProxyDemoWithNoImpl {
    public static void main(String[] args) {
        Car proxy = (Car) Proxy.newProxyInstance(Car.class.getClassLoader(), new Class[]{Car.class},
                new InvocationHandler() {
                    @Override
                    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                        if (method.getName().equals("color")) {
                            System.out.println("喜欢这个颜色吗");
                        }
                        return null;
                    }
                });
        proxy.color();
    }
}
